/**
 * Element Plus 图标工具
 * 解决项目中图标导入和使用的问题
 */

// 导入所有图标
import * as ElementPlusIconsVue from "@element-plus/icons-vue";

// 创建一个图标映射对象，方便在Vue模板中使用
const iconMap = {};

// 遍历所有图标并添加到映射对象中
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
    iconMap[key] = component;
}

/**
 * 获取指定的图标组件
 * @param {string} name - 图标名称
 * @returns {Component|null} - 返回图标组件或null
 */
export function getIcon(name) {
    return iconMap[name] || null;
}

/**
 * 获取所有可用的图标名称
 * @returns {string[]} - 图标名称数组
 */
export function getIconNames() {
    return Object.keys(iconMap);
}

// 导出所有图标
export const Icons = ElementPlusIconsVue;

// 导出一些常用图标的快捷引用
export const Search = ElementPlusIconsVue.Search;
export const ArrowRight = ElementPlusIconsVue.ArrowRight;
export const ArrowLeft = ElementPlusIconsVue.ArrowLeft;
export const ArrowDown = ElementPlusIconsVue.ArrowDown;
export const ArrowUp = ElementPlusIconsVue.ArrowUp;
export const Plus = ElementPlusIconsVue.Plus;
export const Minus = ElementPlusIconsVue.Minus;
export const Close = ElementPlusIconsVue.Close;
export const Check = ElementPlusIconsVue.Check;
export const Info = ElementPlusIconsVue.InfoFilled;
export const Warning = ElementPlusIconsVue.WarningFilled;
export const Error = ElementPlusIconsVue.CircleCloseFilled;
export const Success = ElementPlusIconsVue.CircleCheckFilled;
export const Delete = ElementPlusIconsVue.Delete;
export const Edit = ElementPlusIconsVue.Edit;
export const User = ElementPlusIconsVue.User;
export const Setting = ElementPlusIconsVue.Setting;
export const Home = ElementPlusIconsVue.HomeFilled;
export const Calendar = ElementPlusIconsVue.Calendar;
export const Document = ElementPlusIconsVue.Document;
export const Location = ElementPlusIconsVue.Location;
export const Phone = ElementPlusIconsVue.Iphone;
export const Email = ElementPlusIconsVue.Message;
export const Star = ElementPlusIconsVue.Star;
export const Share = ElementPlusIconsVue.Share;
export const View = ElementPlusIconsVue.View;
export const More = ElementPlusIconsVue.More;
export const OfficeBuilding = ElementPlusIconsVue.OfficeBuilding;
export const School = ElementPlusIconsVue.School;
export const Briefcase = ElementPlusIconsVue.Briefcase;
export const Company = ElementPlusIconsVue.OfficeBuilding;
export const Menu = ElementPlusIconsVue.Menu;
export const Filter = ElementPlusIconsVue.Filter;
export const Sort = ElementPlusIconsVue.Sort;
export const Refresh = ElementPlusIconsVue.Refresh;

// 添加更多图标导出
export const HomeFilled = ElementPlusIconsVue.HomeFilled;
export const UserFilled = ElementPlusIconsVue.UserFilled;
export const Promotion = ElementPlusIconsVue.Promotion;
export const Collection = ElementPlusIconsVue.Collection;
export const Select = ElementPlusIconsVue.Select;
export const Camera = ElementPlusIconsVue.Camera;
export const Download = ElementPlusIconsVue.Download;
export const DocumentCopy = ElementPlusIconsVue.DocumentCopy;

// 添加缺少的图标导出
export const Bell = ElementPlusIconsVue.Bell;
export const ChatDotRound = ElementPlusIconsVue.ChatDotRound;
export const UploadFilled = ElementPlusIconsVue.UploadFilled;
export const Folder = ElementPlusIconsVue.Folder;
export const Upload = ElementPlusIconsVue.Upload;

// 添加更多常用图标导出
export const Message = ElementPlusIconsVue.Message;
export const Clock = ElementPlusIconsVue.Clock;
export const PictureRounded = ElementPlusIconsVue.PictureRounded;
export const Picture = ElementPlusIconsVue.Picture;
export const Link = ElementPlusIconsVue.Link;
export const Time = ElementPlusIconsVue.Time;
export const Position = ElementPlusIconsVue.Position;
export const Compass = ElementPlusIconsVue.Compass;
export const Map = ElementPlusIconsVue.Map;
export const Opportunity = ElementPlusIconsVue.Opportunity;
export const Tickets = ElementPlusIconsVue.Tickets;
export const Coin = ElementPlusIconsVue.Coin;
export const Money = ElementPlusIconsVue.Money;
export const Guide = ElementPlusIconsVue.Guide;
export const Trophy = ElementPlusIconsVue.Trophy;
export const Suitcase = ElementPlusIconsVue.Suitcase;
export const Reading = ElementPlusIconsVue.Reading;
export const Connection = ElementPlusIconsVue.Connection;
export const ChatLineRound = ElementPlusIconsVue.ChatLineRound;
export const ChatLineSquare = ElementPlusIconsVue.ChatLineSquare;
export const ChatSquare = ElementPlusIconsVue.ChatSquare;
export const ChatRound = ElementPlusIconsVue.ChatRound;
export const ShoppingCart = ElementPlusIconsVue.ShoppingCart;
export const ShoppingBag = ElementPlusIconsVue.ShoppingBag;

// 添加Operation图标导出
export const Operation = ElementPlusIconsVue.Operation;

// 添加Notification图标导出
export const Notification = ElementPlusIconsVue.Notification;

// 导出默认对象
export default {
    getIcon,
    getIconNames,
    Icons: ElementPlusIconsVue,
};
